//
//  Account.m
//  DaMaoMall
//
//  Created by HXHL-wally on 16/7/21.
//  Copyright © 2016年 daMao-wally. All rights reserved.
//

#import "Account.h"

@implementation Account

-(instancetype)initWithDict:(NSDictionary *)dict{
    if(self = [super init]){
        self.phone = dict[@"phone"];
        self.userId = dict[@"userId"];
        self.avatar = dict[@"avatar"];
        self.nickname = dict[@"nickname"];
    }
    return self;
}
+(instancetype)accountWithDict:(NSDictionary *)dict{
    return [[self alloc]initWithDict:dict];
}

- (void)encodeWithCoder:(NSCoder *)encoder
{
    [encoder encodeObject:self.phone forKey:@"phone"];
    [encoder encodeObject:self.userId forKey:@"userId"];
    [encoder encodeObject:self.avatar forKey:@"avatar"];
    [encoder encodeObject:self.nickname forKey:@"nickname"];
}
/**
 *  将对象从文件中读入的时候调用, 告诉系统如何读取
 */
- (id)initWithCoder:(NSCoder *)decoder
{
    if (self  = [super init]) {
        self.phone = [decoder decodeObjectForKey:@"phone"];
        self.userId = [decoder decodeObjectForKey:@"userId"];
        self.avatar = [decoder decodeObjectForKey:@"avatar"];
        self.nickname = [decoder decodeObjectForKey:@"nickname"];
    }
    return self;
}


@end
